package com.huo.designmode.singleton;

/**
 * 多线程环境下-懒汉式不能保证只有一个实例对象
 */
public class Person2 {
    private String name;
    private static Person2 person2;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    //提供一个全局的获取person2的方法
    public static Person2 getPerson2() {
        if (person2 ==null){
            return new Person2();
        }
        return person2;
    }

    public static void setPerson2(Person2 person2) {
        Person2.person2 = person2;
    }
}
